using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Input.Touch;
namespace WindowsGame4
{
    public class Planet : Asteroid
    {
        public Turret[] turrets;
        public Specimen[] specimens;
        public Planet()
            : base()
        {
            texture = GameManager.planetTextures[GameManager.random.Next(2)];
            curHealth = maxHealth = 10000;
            regenRate = 100;
            depth = .9f;
            level = maxLevel + 1;
            turrets = new Turret[10];
            for (int i = 0; i < 10; i++)
            {
                turrets[i] = new Turret();
                turrets[i].offsetAngle = i * 360 / (float)10;
                turrets[i].pos=pos+GetDir(turrets[i].offsetAngle)*GetRadius();
                turrets[i].attachTarget = this;
                turrets[i].depth = .09f;
                turrets[i].gun.depth = 0.08f;
                GameManager.AddObject(turrets[i]);
            }
            specimens = new Specimen[10];
            for (int i = 0; i < 10; i++)
            {
                specimens[i]=new Specimen();
                Vector2 dir = GetDir(ParticleEmitter.GetRandom(0, 360));
                specimens[i].offset = dir * ParticleEmitter.GetRandom(0, GetRadius());
                specimens[i].pos = pos + specimens[i].offset;
                specimens[i].depth = .07f;
                GameManager.AddObject(specimens[i]);
            }
           
        }
        public override void Update(float time)
        {
            base.Update(time);
            bool bHasTurrets = false;
            for (int i = 0; i < turrets.Length; i++)
                if (!turrets[i].bDead)
                    bHasTurrets = true;
            if (!bHasTurrets)
                bCollides = false;
            for (int i = 0; i < specimens.Length; i++)
                specimens[i].pos = pos + specimens[i].offset;
        }
        public override void OnDeath()
        {
            base.OnDeath();
            for (int i = 0; i < 10; i++)
            {
                turrets[i].bExplodeOnDeath = bExplodeOnDeath;
                turrets[i].bDead = true;
                specimens[i].bDead = true;
            }
        }
        public override void React(GameObject obj, Vector2 cp)
        {
             base.React(obj, cp);
        }
    }
}
